home *** CD-ROM | disk | FTP | other *** search
-
- ~4Dgifts/toolbox/src/exampleCode/audio/harmonizer README
-
-
- Simple harmonizer - a real-time audio pitch bender example program
-
-
- Usage: harmonizer note1 <note2 note3 ... >
-
- Output is to the standard Indigo audio device (speaker).
-
- Notes are specified by an integer relating the note in
- half steps to middle C.
-
- Middle C would be 0. C# would be 1
-
- for no effect at all : harmonizer 0
- for the chipmunk effect : harmonizer 12
- for a deep voice machine : harmonizer -7
- to simulate a major cord : harmonizer 0 4 7
-
-
- Comments:
-
- Advise running as root or suid root to take advantage of
- memory pinning and non-degrading high priority of audio
- process. To make harmonizer setuid root, run the following
- command:
- chown root harmonizer ; chmod 4755 harmonizer
-
- Libraries you need to compile with come from the Digital
- Media Development option, now up to version 1.1 (for
- systems running IRIX 4.0.X) and version 1.2 (for systems
- running IRIX 5)
-
- Pitch shifting of realtime input from the microphone.
-
- Code isn't optimized.
-
- With the computing power of the indigo R3k, about 4 notes
- can be harmonized simultaneously without a problem.
- R4k does well up to even 8 notes.
-
-
- Harmonizer algorithm :
-
- Assume that the original pitch that we're bending
- has its orginal pitch at MIDDLEC. This is
- an arbitrary starting point and could be anything.
-
- To halve the pitch (move it down an octave) we
- duplicate samples. AS expected, only half of the
- input buffer is used as it gets copied to the audio
- output buffer.
-
- To double the pitch (move it up an octave) we
- just copy every other sample of the original sound
- into the audio output buffer.
-
- Both of these are handled by computing the ratio
- of the original pitch to the desired output pitch.
- And skipping/repeating samples accordingly.
-
- For an octave higher, the ratio is 2.0:1.0 and
- samples are skipped. For an octave lower, the
- ration is 0.5:1.0 and samples are doubled.
- For a musical interval of a perfect fifth higher,
- the ration is 1.5:1.0, etc.
-
- To make calculations based on a piano keyboard, the
- TWELFTH_ROOT_OF_TWO is used as a multiplier to
- find any pitch on the piano keyboard. The number
- of half-steps away a pitch is from MIDDLEC is
- the power that the ratio is raised to. Thus,
- the C-sharp above MIDDLEC has a ratio of
- TWELFTH_ROOT_OF_TWO:1.0 with respect to MIDDLEC.
- The D Natural above MIDDLE C is
- TWELFTH_ROOT_OF_TWO ^ 2 : 1.0 with repect to
- MIDDLEC and so forth.
-
- The output pitch is based on the sampled audio input
- only. So this the time over which the pitch is
- harmonized is discetized and only the audio input
- buffer for that duration of time is used as the
- sample input for the algorithm. Consequently,
- a continuous version of this algorithm (ala
- glissando) would be less efficient to code.
-
-